#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+8;
int n,r[maxn],b[maxn];
bool vis1[maxn],vis2[maxn];
//void cmp(int a,int b){
	//return a>b;
//}
ll ans,left;
ll dfs(int left,int step){
	if(step==n) return left;
	for(int i=1;i<=n;i++){
		vis1[i]=0,vis2[i]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			if(r[i]<r[j]&&vis1[i]==0&&vis2[j]==0){
			    vis1[i]=1;
			    vis2[j]=1;
			    dfs(left-1,step+1);
		    }
		    else{
				dfs(left,step+1);
			}
			if(r[i]<r[j]&&vis1[i]==0&&vis2[j]==0) vis1[i]=0,vis2[j]=0;
		}
	}
	return ans=left;
}
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
		cin>>r[i];
		b[r[i]]++;
	}
	if(b[2]+b[1]==n){
		if(b[1]>=b[2])  ans=b[1];
		else ans=b[2];
		cout<<ans<<endl;
		return 0;
	}
	sort(r+1,r+n+1);
	dfs(n,1);
	//int x=1;
	//while(r[1]==r[1+x]) x++;
	//for(int i=1;i<=n;i++){
	//    dfs(n);
	//	ans=min(ans,left);
	//}
	cout<<ans<<endl;
	return 0;
}

